package com.nowcoder.community.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.util.Date;

/**
 * @author szq
 * @create 2023-01-18 23:18
 * @description 帖子
 */
@Data
@Document(indexName = "discusspost")    // type=_doc、shards=6、replicas=3
@TableName("discuss_post")
public class DiscussPost {
    @Id
    @TableId(type = IdType.AUTO)    // ID自增
    private Integer id;

    @Field(type = FieldType.Integer)
    private int userId;

    // 存储时使用最大的分词器，搜索时使用智能分词器
    @Field(type = FieldType.Text, analyzer = "ik_max_word", searchAnalyzer = "ik_smart")
    private String title;

    @Field(type = FieldType.Text, analyzer = "ik_max_word", searchAnalyzer = "ik_smart")
    private String content;

    @Field(type = FieldType.Integer)
    private int type;       //0-普通; 1-置顶;

    @Field(type = FieldType.Integer)
    private int status;     //0-正常; 1-精华; 2-拉黑;

    @Field(type = FieldType.Date)
    private Date createTime;

    @Field(type = FieldType.Integer)
    private int commentCount;

    @Field(type = FieldType.Double)
    private double score;
}
